#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>

using namespace std;

const int N = 1e5 * 2 + 10;

long long arr[N];
long long f[N];
long long g[N];

int main() {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> arr[i];

    f[0] = g[0] = 0;

    for (int i = 1; i <= n; i++)
    {
        f[i] = g[i - 1] + arr[i];
        g[i] = max(f[i - 1], g[i - 1]);
    }

    cout << max(f[n], g[n]) << endl;

    return 0;
}